<?php

// Exit if accessed directly
if ( !defined('ABSPATH')) exit;

/**
 *
   Template Name:  Home Page
 *
 * @file           homepage.php
 */
?>
<?php get_header(); ?>

        <div id="content" class="grid-right col-700 fit right-home">
        <!-- Box Video -->
        <?php if (have_posts()) : ?>
		<div id="box-video">
		<?php while (have_posts()) : the_post(); ?>
        	<div class="post-entry">
                <?php the_content(__('Read more &#8250;', 'responsive')); ?>
                </div><!-- end of .post-entry -->
        <?php endwhile; ?>
        </div> 
        <?php endif; ?>  
        <!-- End Box Video -->
        
        <!-- Box Service -->
        <div id="list-service">
        	<div class="box-service-title"><h3>Dịch Vụ</h3></div>
        	<?php 
	        $args = array(
	        		'type'                     => 'post',
	        		'child_of'                 => 1,
	        		'parent'                   => '1',
	        		'orderby'                  => 'id',
	        		'order'                    => 'ASC',
	        		'hide_empty'               => 0,
	        		'hierarchical'             => 1,
	        		'exclude'                  => '',
	        		'include'                  => '',
	        		'number'                   => '',
	        		'taxonomy'                 => 'category',
	        		'pad_counts'               => false );
	        $categories = get_categories( $args );
	        foreach ($categories as $category):
	        ?>
	        <div class="box-content">
	        	<?php 
	        	echo '<div class="item-load"><a href="' . get_category_link( $category->term_id ) . '" title="' . $category->name . '" ' . '><img src="'.get_bloginfo('url').'/wp-content/uploads/2013/02/'.$category->slug.'.jpg" /></a></div>';
	        	//echo '<div class="item-intro"><a href="' . get_category_link( $category->term_id ) . '" title="' . $category->name . '" ' . '>Xem Chi Tiết</a></div>';
	        	?>
        	</div>
	        <?php
	        
	        endforeach;
	        ?>
        	<div class="clear"></div>
        </div>
        <!-- End Box Service -->
        
        <!-- Box Action -->
		<!-- Using Category Posts Widget -->
        <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Home Widget 4')) : ?>
		<?php endif;?>
        <!-- End Category Posts Widget -->        
        <!-- End Box Action -->
        
        <!-- Box New -->
		<div id="box-new">
        	<div class="box-service-title"><h2>Thông Tin Giải Trí</h2></div>
			<?php 
			$ID = 13;
			$NUMBEROFPOSTS = 10;
			$result = "<ul class='lcp_catlist'>";
			$catposts = get_posts('category='.$ID."&orderby=title&order=asc&numberposts=".$NUMBEROFPOSTS);
			foreach($catposts as $single):
				$result .= "<li><a href='";
				$result .=get_permalink($single->ID)."'>".$single->post_title."</a></li>";
			endforeach;
			$result .= "</ul>";
			echo $result;
			?>
		</div>
		<!-- End Box New -->
		 <?php 
		 //$parentCatList = get_category_parents(0,true,',');
		 
		 //wp_list_categories('orderby=id&hide_empty=0&child_of=1&title_li=');die;
		/* $args= array(
		  'orderby' => 'name',
		  'parent' => 6
		  );
		$categories = get_categories( $args );
		foreach ( $categories as $category ) {
			echo '<a href="' . get_category_link( $category->term_id ) . '">' . $category->name . '</a><br/>';
		} */
		 /*  $categories=  get_categories('child_of=1'); echo "<pre>";var_dump($categories);echo "</pre>";die;
		  foreach ($categories as $category) {
		  	$option = '<option value="/category/archives/'.$category->category_nicename.'">';
			$option .= $category->cat_name;
			$option .= ' ('.$category->category_count.')';
			$option .= '</option>';
			echo $option;
		  } */
		 ?>
        <?php 
       // $category = get_the_category(1);
       //echo "<pre>";var_dump(get_category_by_slug( 'dich-vu' ));echo "</pre>";die;
       /*  $motorbike_child_cat_args = array(
		    'child_of' => get_category_by_slug( 'dich-vu' )->cat_ID
		);
		
		$motorbike_child_cats = get_categories( 'child_of=1' );
        echo "<pre>";var_dump($motorbike_child_cats);echo "</pre>"; */
       /* 
        * codex.wordpress.org/Function_Reference/get_the_category
        * $args=array(
			  'orderby' => 'name',
			  'order' => 'ASC'
		  );	
$categories=get_categories($args);
  foreach($categories as $category) { 
    echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
    echo '<p> Description:'. $category->description . '</p>';
    echo '<p> Post Count: '. $category->count . '</p>';  
  } */
   /* $result = "<ul class='lcp_catlist'>";
	$catposts = get_posts('category='.$ID."&orderby=title&order=asc&numberposts=".$NUMBEROFPOSTS);
	foreach($catposts as $single):
		$result .= "<li><a href='";
		$result .=get_permalink($single->ID)."'>".$single->post_title."</a></li>";
	endforeach;
	$result .= "</ul>";
	echo $result; */
	?>
	<?php
//wp_list_categories('orderby=id&show_count=0&use_desc_for_title=0&title_li=Dịch Vụ&child_of=1');
?>
        </div><!-- end of #content -->

<?php get_sidebar('left'); ?>
<?php get_footer(); ?>
